{extend name="../../admin/view/main"}

{block name="button"}

{/block}

{block name="content"}
<div class="layui-tab layui-tab-card think-bg-white">
    <div class="layui-tab-content table-block">
        {include file='config_file_record/index_search'}
        <table class="layui-table" lay-skin="line">
            {notempty name='list'}
            <thead>
            <tr>
                <th class='list-table-check-td think-checkbox'>
                    <label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
                </th>
                <th class='text-left'>ID</th>
                <th class='text-left'>文件列表</th>
                <th class='text-left'>发布用户</th>
                <th class='text-left'>发布时间</th>
                <th class="text-left" style="width: 140px;">操作</th>
                <th></th>
            </tr>
            </thead>
            {/notempty}
            <tbody>
            {foreach $list as $key=>$vo}
            <tr>
                <td class='list-table-check-td think-checkbox'>
                    <label><input class="list-check-box" value='{$vo.id}' type='checkbox'></label>
                </td>
                <td class='text-left '>{$vo.id|default=''}</td>
                <td class='text-left '>
                    {foreach $vo.config_file as $kk=>$file_name}
                    {$file_name|default=''}
                    <br>
                    {/foreach}
                </td>
                <td class='text-left '>{$vo.manager_name|default=''}</td>
                <td class='text-left '>{$vo.created_at|default=''}</td>
                <td class='text-left '>
                    <button class="layui-btn layui-btn-sm" onclick="downloadFile('{$vo.id}')">导 出</button>
                </td>
            </tr>
            {/foreach}
            </tbody>
        </table>
        <div style="margin-top: -5px;">{empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
        </div>
    </div>
</div>

<script>
    function downloadFile(myId) {
        // 创建一个隐藏的表单
        var form = $('<form></form>');
        form.attr('method', 'POST');
        form.attr('action', '/airobot/config_file_record/download.html?spm=m-25-91-92'); // PHP 文件路径

        // 添加要发送的数据
        var input = $('<input type="hidden" name="id" value="' + myId + '">');
        form.append(input);

        // 将表单添加到 body 中并提交
        $('body').append(form);
        form.submit();
        form.remove(); // 提交后移除表单
    }
</script>
{/block}